home *** CD-ROM | disk | FTP | other *** search
- SimpleTask.bas - Task creation and co-ordination from BASIC
- ===========================================================
-
- Derived from RKM example (c) Copyright 1992 Commodore-Amiga, Inc.
-
- This is a variant on the Commodore example "Task creation with Amiga.lib",
- taken from the Libraries RKM p.467.
-
- The example shows how multi-tasking programs in BASIC are possible. It borrows
- the Hook idea to start the task (although Hooks were added as part of V36
- there is nothing about them which stops them being used on any vintage of the
- Amiga OS), the code for starting the task is a variant on the ExecSupport.bas
- CreateTask, named CreateHookEntryTask; this FUNCTION creates the necessary
- task structures and the hook for retrieving the BASIC runtime context in the
- context of the child task. The TaskHookEntry.s file is used to glue the task
- entry point to the BASIC hook entry point. Both these files are stored in the
- BH:BLib/ sub-directory.
-
- Note that using tasks is _not_ for the faint hearted, you must be thinking at
- all times about what your are asking the compiler and its runtime system to
- do (since the code must be re-entrant). If you try something like PRINT for
- example in the sub-task the machine will crash horribly with no indication of
- what went wrong - what went wrong is PRINT uses DOS, which a task cannot call,
- even if we were using a process (which can call DOS) the machine would still
- most likely crash as PRINT is a complex involved BASIC statement which is
- almost certainly not re-entrant.
-
- The example will work on all non-obsolete versions of Workbench (V33 and
- above).
-
- Compiling
- ---------
- Load the SimpleTask_inc.bh file and Tokenise it (Program-Tokenise), making
- sure you have no token file selected in the File Options (Settings-Compiler-
- Files). Once you have your token file, set the File Options-Token File setting
- to the SimpleTask_inc.t file just created. Load the SimpleTask.bas file then
- compile & run it. Note that the TaskHookEntry.s file is effectively embedded
- in the task creation routines.
-